package com.leyou.gateway.config;

import org.springframework.cloud.gateway.filter.ratelimit.KeyResolver;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.server.ServerWebExchange;
import reactor.core.publisher.Mono;

/**
 * <h3>leyou-project</h3>
 * <p></p>
 *
 * @author : hhw
 * @date : 2020-05-20 20:42
 **/
@Configuration
public class RateLimitConfig {

    @Bean
    public KeyResolver ipKeyResolver(){
        return (exchange)->Mono.just(exchange.getRequest().getRemoteAddress().getHostName());   //获取用户IP地址
    }

}
